package cn.jhc.bean;

import java.util.Date;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

@Entity
@Table(name="student")
public class Student {
	
	private Integer sid;
	private String sno;
	private String spassword;
	private String sname;
	private String sex;
	private String cardid;
	private Date entertime;
	private Date gradtime;

	private Clazz clazz;
	private Set<Payment> payments;
	private Set<Score> scores = new HashSet<Score>();
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="SID")
	public Integer getId() {
		return sid;
	}
	public void setId(Integer sid) {
		this.sid = sid;
	}
	@Column(name="SNO",columnDefinition="varchar(255)",unique = true)
	public String getSno() {
		return sno;
	}
	
	public void setSno(String sno) {
		this.sno = sno;
	}
	@Column(name="SPASSWORD",columnDefinition="varchar(255)")
	public String getSpassword() {
		return spassword;
	}
	public void setSpassword(String spassword) {
		this.spassword = spassword;
	}
	@Column(name="SNAME",columnDefinition="varchar(255)",nullable=false)
	public String getSname() {
		return sname;
	}
	
	public void setSname(String sname) {
		this.sname = sname;
	}
	
	@Column(name="SEX",columnDefinition="varchar(255)")
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	@Column(name="CARDID")
	public String getCardid() {
		return cardid;
	}
	public void setCardid(String cardid) {
		this.cardid = cardid;
	}
	
	@Column(name="ENTERTIME")
	public Date getEntertime() {
		return entertime;
	}
	public void setEntertime(Date entertime) {
		this.entertime = entertime;
	}
	@Column(name="GRADTIME")
	public Date getGradtime() {
		return gradtime;
	}
	public void setGradtime(Date gradtime) {
		this.gradtime = gradtime;
	}
	@ManyToOne
	@Cascade (org.hibernate.annotations.CascadeType.SAVE_UPDATE)
	@JoinColumn(name="CLASSNO",nullable=false)
	public Clazz getClazz() {
		return clazz;
	}
	public void setClazz(Clazz clazz) {
		this.clazz = clazz;
	}
	@OneToMany(mappedBy="student")
	@Cascade (org.hibernate.annotations.CascadeType.SAVE_UPDATE)
	public Set<Payment> getPayments() {
		return payments;
	}
	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}
	@OneToMany(mappedBy="student")
	@Cascade (org.hibernate.annotations.CascadeType.SAVE_UPDATE)
	public Set<Score> getScores() {
		return scores;
	}
	public void setScores(Set<Score> scores) {
		this.scores = scores;
	}
	

}
